var Region = {
	createNew: function(){
		var p = {
			name: "",
			belongs: 0,
			areas: {
				total: 0,
				forest: 0,
				fields: 0,
				grass: 0,
				town: 0,
				desert: function(){
					return this.total - this.forest - this.fields - this.grass - this.town;
				}
			},
			
			population: 0,
			labur: 0,
			healthy: 0,
			people_money: 0,

			storage: {
				golds: 0,
				rice: 0,
				bow: 0,
				horse: 0,
				sword: 0,
				armour: 0,
				
			}

		}

		p.load = function(){

		}

		p.save = function(){

		}




		return p;
	}

}







var Person = {
	createNew: function(){
		var p = {
			name: 'qwerty',
			sex: 0,
			power: 0,
			powerExp: 0,
			wise: 0,
			wiseExp: 0,
			glame: 0,
			rank: 0,
			official: 0,
			exp: 0,
		}

		p.leadship = function(){
			let b = this.power > this.wise ? this.power : this.wise;
			let s = this.power < this.wise ? this.power : this.wise;
			return Math.ceil(b * 0.6 + s * 0.2 + this.glame * 0.2);
		}

		p.poli = function(){
			return Math.ceil(this.power * 0.3 + this.wise * 0.6 + this.glame * 0.1);
		}



		return p;
	}


}




var Troop = {

	index: 0,
	troopTypes: [
		{name: '步', att: 2, def: 1, speed: 2, distance: 1, sword: 1, bow: 0, armour: 0, horse: 0},
		{name: '重步', att: 3, def: 3, speed: 1, distance: 1, sword: 1, bow: 0, armour: 1, horse: 0},
		{name: '弓', att: 1, def: 1, speed: 2, distance: 5, sword: 0, bow: 1, armour: 0, horse: 0},
		{name: '重弓', att: 2, def: 3, speed: 1, distance: 4, sword: 0, bow: 1, armour: 1, horse: 0},
		{name: '轻骑', att: 3, def: 2, speed: 6, distance: 1, sword: 1, bow: 0, armour: 0, horse: 1},
		{name: '重骑', att: 4, def: 4, speed: 4, distance: 1, sword: 1, bow: 0, armour: 1, horse: 1},
		{name: '弓骑', att: 2, def: 2, speed: 6, distance: 5, sword: 0, bow: 1, armour: 0, horse: 1},
		{name: '重弓骑', att: 3, def: 4, speed: 4, distance: 4, sword: 0, bow: 1, armour: 1, horse: 1},
	],  

	createNew: function(troopTypeID){
		var trooptypeid = troopTypeID || 0;
		var p = {
			index: Troop.index,
			status: 1,
			soldiors: 0,
			exp: 0,
			trill: 0,
		}
		p.tt = rd.clone(Troop.troopTypes[trooptypeid]);  // tt means troop type
		p.troopType = function(){ return this.tt.name;}
		p.attack = function(){ return this.tt.att * this.soldiors;}
		p.deffence = function(){ return this.tt.def * this.soldiors;}
		p.speed = function(){ return this.tt.speed; }
		p.distance = function(){ return this.tt.distance; }
		p.sword = function(){ return this.tt.sword * this.soldiors; }
		p.bow = function(){ return this.tt.bow * this.soldiors; }
		p.armour = function(){ return this.tt.armour * this.soldiors; }
		p.horse = function(){ return this.tt.horse * this.soldiors; }


		// p.changeTroopType = function(troopTypeID){   ----------troop type 暂时不允许变更-------------
		// 	this.tt = rd.clone(Troop.troopTypes[troopTypeID]);
		// }

		Troop.index ++;
		return p;
	}, 

	// 推导数据








}

var Army = {
	createNew: function(){
		var p = {
			troops : [],
			leader: null,
			
		}

		return p;
	}
}